/*
 * JukeboxProperties.java
 *
 * Created on March 3, 2005, 8:40 AM
 */
package com.bff.slimserver.musicjukebox.lib;

import com.bff.bjj.AbstractJukeboxProperties;
import com.bff.bjj.utils.Resources;
import com.bff.slimserver.music.exceptions.PlayerException;
import com.bff.slimserver.music.exceptions.PlaylistException;
import com.bff.slimserver.musicjukebox.lib.events.PlayerChosenEvent;
import com.bff.slimserver.musicjukebox.lib.events.PlayerChosenListener;
import com.bff.slimserver.musicjukebox.lib.events.SettingsChangedEvent;
import com.bff.slimserver.musicjukebox.lib.events.SettingsChangedListener;
import com.bff.bjj.utils.Utils;
import java.awt.Image;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bff.slimserver.SlimDatabase;
import org.bff.slimserver.SlimFavoritePlugin;
import org.bff.slimserver.SlimFolderBrowser;
import org.bff.slimserver.SlimPlayer;
import org.bff.slimserver.SlimPlaylist;
import org.bff.slimserver.SlimPodcaster;
import org.bff.slimserver.SlimRadioPlugin;
import org.bff.slimserver.SlimSavedPlaylistManager;
import org.bff.slimserver.SlimServer;
import org.bff.slimserver.events.PlayerChangeEvent;
import org.bff.slimserver.events.PlayerChangeListener;
import org.bff.slimserver.exception.SlimConnectionException;
import org.bff.slimserver.exception.SlimException;
import org.bff.slimserver.monitor.SlimStandAloneMonitor;

/**
 *
 * @author bill
 */
public class JukeboxProperties extends AbstractJukeboxProperties {

    private SlimPlaylist playlist;
    private SlimPlayer player;
    private SlimDatabase database;
    private SlimSavedPlaylistManager playlistManager;
    private SlimRadioPlugin radioPlugin;
    private SlimFavoritePlugin favoritePlugin;
    private SlimFolderBrowser folderBrowser;
    private SlimPodcaster podcaster;
    private SlimStandAloneMonitor slimMonitor;
    private String server;
    private String user;
    private String password;
    private String lastPlayerId;
    private int port;
    private int webPort;
    private boolean showCoverArt;
    private boolean showGuitarPanel;
    private boolean showAlbumsPanel;
    private boolean showPodcastPanel;
    private boolean showRadiosPanel;
    private boolean showServicesPanel;
    private boolean showFavoritesPanel;
    private boolean showNewMusicPanel;
    private boolean checkForUpdate;
    private int imageDelay = -1;
    private SlimServer slimServer;
    private int clientType;
    private int coverSize;
    private boolean useTreeExplorer;
    private boolean stopOnExit;
    private static final String PROP_FILE = "musicjukeboxss.properties";
    private static final String PROP_FILE_DIR = System.getProperty("user.home")
            + Resources.FILE_SEPARATOR
            + ".bjj";
    private static final String PROP_FILE_NAME = PROP_FILE_DIR
            + Resources.FILE_SEPARATOR
            + PROP_FILE;
    private static final String PROP_SERVER = "slim.server";
    private static final String PROP_PORT = "slim.port";
    private static final String PROP_WEB_PORT = "slim.webserver";
    private static final String PROP_SLIM_USER = "slim.user";
    private static final String PROP_SLIM_PASSWORD = "slim.password";
    private static final String PROP_IMAGE_DELAY = "image.delay";
    private static final String PROP_LAST_PLAYER = "slim.playerid";
    private static final String PROP_COVER_ART = "art.cover";
    private static final String PROP_GUITAR_PANEL = "guitar.panel";
    private static final String PROP_ALBUMS_PANEL = "album.panel";
    private static final String PROP_PODCAST_PANEL = "podcast.panel";
    private static final String PROP_RADIOS_PANEL = "radios.panel";
    private static final String PROP_SERVICES_PANEL = "services.panel";
    private static final String PROP_FAVORITES_PANEL = "favorites.panel";
    private static final String PROP_NEW_MUSIC_PANEL = "newmusic.panel";
    private static final String PROP_CLIENT_TYPE = "slim.clienttype";
    private static final String PROP_IMAGE_SIZE = "art.size";
    private static final String PROP_EXPLORER_TYPE = "explorer.type";
    private static final String PROP_EXIT_STOP = "exit.stop";
    private static final String PROP_PLAYLIST_ALBUM_ART = "playlist.art";
    private static final String PROP_ALBUM_LIST_ART = "albumlist.art";
    private static final String PROP_CHECK_UPDATE = "check.update";
    private static final String PROP_INCLUDE_THE = "include.the";
    private List<SettingsChangedListener> settingsListeners;
    public static final int DEFAULT_IMAGE_DELAY = 2;
    public static final int MAX_IMAGE_DELAY = 30;
    private static JukeboxProperties instance;
    private static final int DEFAULT_PORT = 9090;
    private static final int DEFAULT_WEB_PORT = 9000;
    private static final int DEFAULT_SLIM_DELAY = 1000;
    public static final int CLIENT_PLAYER_LEFT = 10;
    public static final int CLIENT_PLAYER_TOP = 11;
    private List<PlayerChosenListener> playerListeners =
            new ArrayList<PlayerChosenListener>();
    private boolean playlistAlbumArt;
    private boolean albumListArt;
    private boolean includeThe;

    /**
     * Returns singleton properties class.  If the properties file exists the
     * properties are loaded.  If not everything will be null so make sure to
     * check exists() if necessary.
     * 
     * @return
     */
    public static JukeboxProperties getInstance() throws PlayerException {
        if (instance == null) {
            instance = new JukeboxProperties();
        }

        return instance;
    }

    /**
     * Adds a {@link PlayerChangeListener} to this object to receive
     * {@link PlayerChangeEvent}s.
     * @param pcl the PlayerChangeListener to add
     */
    public synchronized void addPlayerChosenListener(PlayerChosenListener pcl) {
        playerListeners.add(pcl);
    }

    /**
     * Removes a {@link PlayerChangeListener} from this object.
     * @param pcl the PlayerChangeListener to remove
     */
    public synchronized void removePlayerChosenListener(PlayerChosenListener pcl) {
        playerListeners.remove(pcl);
    }

    public boolean isPlaylistAlbumArt() {
        return playlistAlbumArt;
    }

    public void removeProperties() {
        new File(PROP_FILE_NAME).delete();
    }

    public void setPlaylistAlbumArt(boolean b) {
        this.playlistAlbumArt = b;
        saveSettings();
    }

    /**
     * Sends the appropriate {@link PlayerChangeEvent} to all registered
     * {@link PlayerChangeListener}s.
     * @param id the event id to send
     */
    protected synchronized void firePlayerChosenEvent(int id, SlimPlayer player) {
        PlayerChosenEvent pce = new PlayerChosenEvent(this, id, player);

        for (PlayerChosenListener pcl : playerListeners) {
            pcl.playerChosen(pce);
        }
    }

    public Image getTableImage() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private String getLastPlayerId() {
        return this.lastPlayerId;
    }

    private void setLastPlayerId(String playerId, boolean persist) {
        this.lastPlayerId = playerId;
        if (persist) {
            saveSettings();
        }
    }

    public int getWebPort() {
        if (webPort == 0) {
            return DEFAULT_WEB_PORT;
        }
        return webPort;
    }

    public void setWebPort(int webPort) {
        this.webPort = webPort;
    }

    public int getPort() {
        if (port == 0) {
            return DEFAULT_PORT;
        }
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    /** Creates a new instance of JukeboxProperties */
    private JukeboxProperties() {
        settingsListeners = new ArrayList<SettingsChangedListener>();
        if (exists()) {
            try {
                loadProperties();
            } catch (PlayerException ex) {
                Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
                throw ex;
            }
        }
    }

    public static boolean exists() {
        File propFile = new File(PROP_FILE_NAME);
        if (propFile.exists()) {
            return (true);
        } else {
            //see if the old prop file is there and copy
            File oldPropFile = new File(PROP_FILE);
            if (oldPropFile.exists()) {
                new File(PROP_FILE_DIR).mkdir();
                try {
                    Utils.copyFile(oldPropFile, propFile);
                    oldPropFile.delete();
                    return true;
                } catch (IOException ex) {
                    Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            return (false);
        }
    }

    public boolean saveSettings() {
        if (saveSettings(
                getServer(),
                getPort(),
                getWebPort(),
                getUser(),
                getPassword(),
                getImageDelay(),
                getLastPlayerId(),
                isShowCoverArt(),
                getClientType(),
                getCoverSize(),
                isTrayMin(),
                isUseTreeExplorer(),
                isShowGuitarPanel(),
                isShowAlbumsPanel(),
                isShowPodcastPanel(),
                isShowFavoritesPanel(),
                isShowRadiosPanel(),
                isShowServicesPanel(),
                isShowNewMusicPanel(),
                isStopOnExit(),
                isCheckForUpdate(),
                isIncludeThe(),
                isTrayAlways(),
                isGroupByFolder(),
                isPlaylistAlbumArt(),
                isAlbumListArt())) {
            return (true);
        } else {
            return (false);
        }
    }

    public boolean saveSettings(String server,
            int port,
            int webPort,
            String user,
            String password,
            int imageDelay,
            String playerId,
            boolean showCoverArt,
            int clientType,
            int coverSize,
            boolean minTray,
            boolean useTreeExplorer,
            boolean showGuitarPanel,
            boolean showAlbumsPanel,
            boolean showPodcastPanel,
            boolean showFavoritesPanel,
            boolean showRadiosPanel,
            boolean showServicesPanel,
            boolean showNewMusicPanel,
            boolean stopOnExit,
            boolean checkForUpdate,
            boolean includeThe,
            boolean alwaysTray,
            boolean groupByFolder,
            boolean playlistAlbumArt,
            boolean albumListArt) {

        try {
            Properties props = new Properties();
            props.setProperty(PROP_SERVER, server);
            props.setProperty(PROP_SLIM_USER, user == null ? "" : user);
            props.setProperty(PROP_PORT, Integer.toString(port));
            props.setProperty(PROP_WEB_PORT, Integer.toString(webPort));
            props.setProperty(PROP_SLIM_PASSWORD, password == null ? "" : password);
            props.setProperty(PROP_IMAGE_DELAY, Integer.toString(imageDelay < 0 ? DEFAULT_IMAGE_DELAY : imageDelay));
            props.setProperty(PROP_LAST_PLAYER, playerId == null ? "" : playerId);
            props.setProperty(PROP_COVER_ART, Boolean.toString(showCoverArt));
            props.setProperty(PROP_MIN_TRAY, Boolean.toString(minTray));
            props.setProperty(PROP_ALWAYS_TRAY, Boolean.toString(alwaysTray));
            props.setProperty(PROP_CLIENT_TYPE, Integer.toString(clientType));
            props.setProperty(PROP_IMAGE_SIZE, Integer.toString(coverSize));
            props.setProperty(PROP_EXPLORER_TYPE, isUseTreeExplorer() ? "tree" : "list");
            props.setProperty(PROP_GUITAR_PANEL, Boolean.toString(showGuitarPanel));
            props.setProperty(PROP_ALBUMS_PANEL, Boolean.toString(showAlbumsPanel));
            props.setProperty(PROP_PODCAST_PANEL, Boolean.toString(showPodcastPanel));
            props.setProperty(PROP_FAVORITES_PANEL, Boolean.toString(showFavoritesPanel));
            props.setProperty(PROP_NEW_MUSIC_PANEL, Boolean.toString(showNewMusicPanel));
            props.setProperty(PROP_RADIOS_PANEL, Boolean.toString(showRadiosPanel));
            props.setProperty(PROP_SERVICES_PANEL, Boolean.toString(showServicesPanel));
            props.setProperty(PROP_EXIT_STOP, Boolean.toString(stopOnExit));
            props.setProperty(PROP_PLAYLIST_ALBUM_ART, Boolean.toString(playlistAlbumArt));
            props.setProperty(PROP_ALBUM_LIST_ART, Boolean.toString(albumListArt));
            props.setProperty(PROP_CHECK_UPDATE, Boolean.toString(checkForUpdate));
            props.setProperty(PROP_INCLUDE_THE, Boolean.toString(includeThe));
            props.setProperty(PROP_GROUP_FOLDER, Boolean.toString(groupByFolder));
            saveMusicProperties(props);
            fireSettingsChangedEvent();
        } catch (Exception e) {
            e.printStackTrace();
            return (false);

        }
        return (true);
    }

    private void saveMusicProperties(Properties props) throws Exception {
        File dir = new File(PROP_FILE_DIR);
        if (!dir.exists()) {
            dir.mkdir();
        }

        FileOutputStream outFile = null;
        try {
            outFile = new FileOutputStream(PROP_FILE_NAME);
            props.store(outFile, null);
        } catch (Exception e) {
            throw e;
        } finally {
            outFile.close();
        }
    }

    private synchronized void loadProperties() throws PlayerException {
        FileInputStream inFile = null;
        try {
            inFile = new FileInputStream(PROP_FILE_NAME);
            Properties props = new Properties();
            props.load(inFile);
            setShowCoverArt(Boolean.valueOf(props.getProperty(PROP_COVER_ART)));
            setTrayMin(Boolean.valueOf(props.getProperty(PROP_MIN_TRAY, "false")));
            setTrayAlways(Boolean.valueOf(props.getProperty(PROP_ALWAYS_TRAY, "false")));
            setServer(props.getProperty(PROP_SERVER));
            setPort(Integer.parseInt(props.getProperty(PROP_PORT)));
            setClientType(Integer.parseInt(props.getProperty(PROP_CLIENT_TYPE, Integer.toString(CLIENT_PLAYER_TOP))));
            setUseTreeExplorer(props.getProperty(PROP_EXPLORER_TYPE, "list").equals("tree") ? true : false);
            setWebPort(Integer.parseInt(props.getProperty(PROP_WEB_PORT)));
            setUser(props.getProperty(PROP_SLIM_USER));
            setPassword(props.getProperty(PROP_SLIM_PASSWORD));
            setLastPlayerId(props.getProperty(PROP_LAST_PLAYER) == null ? "" : props.getProperty(PROP_LAST_PLAYER), false);
            setCoverSize(Integer.parseInt(props.getProperty(PROP_IMAGE_SIZE, "200")));
            setStopOnExit(Boolean.valueOf(props.getProperty(PROP_EXIT_STOP, "false")));
            setShowGuitarPanel(Boolean.valueOf(props.getProperty(PROP_GUITAR_PANEL, "false")));
            setShowAlbumsPanel(Boolean.valueOf(props.getProperty(PROP_ALBUMS_PANEL, "true")));
            setShowPodcastPanel(Boolean.valueOf(props.getProperty(PROP_PODCAST_PANEL, "true")));
            setShowFavoritesPanel(Boolean.valueOf(props.getProperty(PROP_FAVORITES_PANEL, "true")));
            setShowNewMusicPanel(Boolean.valueOf(props.getProperty(PROP_NEW_MUSIC_PANEL, "true")));
            setShowRadiosPanel(Boolean.valueOf(props.getProperty(PROP_RADIOS_PANEL, "true")));
            setShowServicesPanel(Boolean.valueOf(props.getProperty(PROP_SERVICES_PANEL, "true")));
            setPlaylistAlbumArt(Boolean.valueOf(props.getProperty(PROP_PLAYLIST_ALBUM_ART, "true")));
            setAlbumListArt(Boolean.valueOf(props.getProperty(PROP_ALBUM_LIST_ART)));
            setCheckForUpdate(Boolean.valueOf(props.getProperty(PROP_CHECK_UPDATE, "true")));
            setIncludeThe(Boolean.valueOf(props.getProperty(PROP_INCLUDE_THE, "false")));
            setGroupByFolder(Boolean.valueOf(props.getProperty(PROP_GROUP_FOLDER, "false")));
            try {
                loadPlayer();
            } catch (PlayerException ex) {
                Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
                try {
                    setPlayer(getAllPlayers().get(0));
                } catch (SlimException ex1) {
                    Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex1);
                } catch (PlaylistException ex1) {
                    Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex1);
                } catch (Exception e) {
                    Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, e);
                }

                if (getPlayer() == null) {
                    throw new PlayerException(PlayerException.ERROR.NO_PLAYER_ATTACHED, "No players attached.");
                }
            }

            try {
                setSlimMonitor(new SlimStandAloneMonitor(getPlayer(), DEFAULT_SLIM_DELAY));
                getSlimMonitor().start();
                int delay = Integer.parseInt(props.getProperty(PROP_IMAGE_DELAY));
                //for backward compatibility
                if (delay > 1000) {
                    delay = delay / 1000;
                }
                setImageDelay(delay);
            } catch (Exception e) {
                setImageDelay(DEFAULT_IMAGE_DELAY);
            }

        } catch (Exception ex) {
            if(ex instanceof PlayerException) {
                throw (PlayerException)ex;
            }
            Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                inFile.close();
            } catch (IOException ex) {
                Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public SlimDatabase getDatabase() throws SlimConnectionException {
        if (database == null) {
            database = new SlimDatabase(getSlimServer());
        }

        return database;
    }

    public SlimSavedPlaylistManager getPlaylistManager() throws SlimConnectionException {
        if (playlistManager == null) {
            playlistManager = new SlimSavedPlaylistManager(getSlimServer());
        }

        return playlistManager;
    }

    public SlimRadioPlugin getRadioPlugin() throws SlimConnectionException {
        if (radioPlugin == null) {
            radioPlugin = new SlimRadioPlugin(getSlimServer());
        }

        return radioPlugin;
    }

    public SlimFavoritePlugin getFavoritesPlugin() throws SlimConnectionException {
        if (favoritePlugin == null) {
            favoritePlugin = new SlimFavoritePlugin(getSlimServer());
        }

        return favoritePlugin;
    }

    public SlimFolderBrowser getFolderBrowser() throws SlimConnectionException {
        if (folderBrowser == null) {
            folderBrowser = new SlimFolderBrowser(getSlimServer());
        }

        return folderBrowser;
    }

    public SlimPodcaster getPodcaster() throws SlimConnectionException {
        if (podcaster == null) {
            podcaster = new SlimPodcaster(getSlimServer());
        }

        return podcaster;
    }

    /**
     * Must set player first
     * @return
     * @throws com.bff.music.exceptions.PlaylistException
     */
    public SlimPlaylist getPlaylist() throws PlaylistException {
        try {
            if (getPlayer() == null) {
                throw new PlaylistException("Player not set.");
            }
            return this.playlist;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PlaylistException(e.getMessage());
        }
    }

    private SlimPlaylist getPlaylist(SlimPlayer player) throws PlaylistException {
        if (this.playlist == null) {
            try {
                this.playlist = new SlimPlaylist(player);
            } catch (Exception e) {
                e.printStackTrace();
                throw new PlaylistException(e.getMessage());
            }
        }
        return (this.playlist);
    }

    public void loadPlayer() throws PlayerException {
        if (getLastPlayerId() == null || "".equals(getLastPlayerId())) {
            try {
                setPlayer(getAllPlayers().get(0));
            } catch (Exception e) {
                throw new PlayerException(PlayerException.ERROR.OTHER_ERROR, e.getMessage());
            }
        } else {
            try {
                for (SlimPlayer pl : getAllPlayers()) {
                    if (pl.getId().equals(getLastPlayerId())) {
                        setPlayer(pl);
                    }
                }

                if (getPlayer() == null) {
                    setPlayer(getAllPlayers().get(0));
                }
            } catch (Exception e) {
                throw new PlayerException(PlayerException.ERROR.OTHER_ERROR, e.getMessage());
            }
        }
    }

    /**
     * 
     * @param persist save file as last player
     * @return
     * @throws com.bff.music.exceptions.PlayerException
     */
    public SlimPlayer getPlayer() {
        return (player);
    }

    public synchronized void setPlayer(SlimPlayer player) throws PlaylistException, IOException {
        this.player = player;
        setLastPlayerId(player.getId(), true);
        setPlaylist(getPlaylist(player));
        if (getSlimMonitor() != null) {
            try {
                getSlimMonitor().setPlayer(player);
                getPlaylist().setPlayer(player);
            } catch (SlimException ex) {
                Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        firePlayerChosenEvent(PlayerChosenEvent.PLAYER_CHOSEN, player);
    }

    public List<SlimPlayer> getAllPlayers() throws SlimConnectionException {
        return new ArrayList<SlimPlayer>(getSlimServer().getSlimPlayers());
    }

    public final void kill() {
        try {
            player.stop();
            player = null;
            setPlaylist(null);
        } catch (SlimConnectionException ex) {
            Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /*
    public boolean isShowTableImage() {
    return showTableImage;
    }
    
    public void setShowTableImage(boolean aShowTableImage) {
    showTableImage = aShowTableImage;
    }
     */
    public SlimServer getSlimServer() throws SlimConnectionException {
        if (slimServer == null) {
            if (getUser() == null) {
                slimServer = new SlimServer(getServer(), getPort(), getWebPort());
            } else {
                slimServer = new SlimServer(getServer(), getPort(), getWebPort(), getUser(), getPassword());
            }
        }

        return (slimServer);
    }

    public String getServer() {
        return server;
    }

    public void setServer(String server) {
        this.server = server;
    }

    public String getUser() {
        return user;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * in seconds
     * @return
     */
    public int getImageDelay() {
        return imageDelay;
    }

    public int getImageDelayInMillis() {
        return imageDelay * 1000;
    }

    public void setImageDelay(int imageDelay) {
        this.imageDelay = imageDelay;
    }

    public boolean isShowCoverArt() {
        return showCoverArt;
    }

    public void setShowCoverArt(boolean showCoverArt) {
        this.showCoverArt = showCoverArt;
    }

    public void setPlaylist(SlimPlaylist playlist) {
        this.playlist = playlist;
    }

    public SlimStandAloneMonitor getSlimMonitor() {
        return slimMonitor;
    }

    public void setSlimMonitor(SlimStandAloneMonitor slimMonitor) {
        this.slimMonitor = slimMonitor;
    }

    public int getClientType() {
        return clientType;
    }

    public void setClientType(int clientType) {
        this.clientType = clientType;
    }

    public void resetProperties() {
        instance = null;
    }

    public int getCoverSize() {
        return coverSize;
    }

    public void setCoverSize(int coverSize) {
        this.coverSize = coverSize;
    }

    public static void main(String[] args) {
        System.out.println(Double.parseDouble("0.1"));
    }

    public String getHomeUrl() {
        try {
            return "http://" + getSlimServer().getServer() + ":" + getSlimServer().getWebPort();
        } catch (SlimConnectionException ex) {
            Logger.getLogger(JukeboxProperties.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }

    public boolean isUseTreeExplorer() {
        return useTreeExplorer;
    }

    public void setUseTreeExplorer(boolean useTreeExplorer) {
        this.useTreeExplorer = useTreeExplorer;
    }

    private void fireSettingsChangedEvent() {
        for (SettingsChangedListener listener : settingsListeners) {
            listener.settingsChanged(new SettingsChangedEvent(this));
        }
    }

    public void addSettingsChangedListener(SettingsChangedListener listener) {
        settingsListeners.add(listener);
    }

    public void removeSettingsChangedListener(SettingsChangedListener listener) {
        settingsListeners.remove(listener);
    }

    /**
     * @return the showGuitarPanel
     */
    public boolean isShowGuitarPanel() {
        return showGuitarPanel;
    }

    /**
     * @param showGuitarPanel the showGuitarPanel to set
     */
    public void setShowGuitarPanel(boolean showGuitarPanel) {
        this.showGuitarPanel = showGuitarPanel;
    }

    /**
     * @return the stopOnExit
     */
    public boolean isStopOnExit() {
        return stopOnExit;
    }

    /**
     * @param stopOnExit the stopOnExit to set
     */
    public void setStopOnExit(boolean stopOnExit) {
        this.stopOnExit = stopOnExit;
    }

    /**
     * @return the albumListArt
     */
    public boolean isAlbumListArt() {
        return albumListArt;
    }

    /**
     * @param albumListArt the albumListArt to set
     */
    public void setAlbumListArt(boolean albumListArt) {
        this.albumListArt = albumListArt;
        saveSettings();
    }

    /**
     * @return the showAlbumsPanel
     */
    public boolean isShowAlbumsPanel() {
        return showAlbumsPanel;
    }

    /**
     * @param showAlbumsPanel the showAlbumsPanel to set
     */
    public void setShowAlbumsPanel(boolean showAlbumsPanel) {
        this.showAlbumsPanel = showAlbumsPanel;
    }

    /**
     * @return the showPodcastPanel
     */
    public boolean isShowPodcastPanel() {
        return showPodcastPanel;
    }

    /**
     * @param showPodcastPanel the showPodcastPanel to set
     */
    public void setShowPodcastPanel(boolean showPodcastPanel) {
        this.showPodcastPanel = showPodcastPanel;
    }

    public boolean isShowFavoritesPanel() {
        return showFavoritesPanel;
    }

    /**
     * @param showPodcastPanel the showPodcastPanel to set
     */
    public void setShowFavoritesPanel(boolean showFavoritesPanel) {
        this.showFavoritesPanel = showFavoritesPanel;
    }

    /**
     * @return the showRadiosPanel
     */
    public boolean isShowRadiosPanel() {
        return showRadiosPanel;
    }

    /**
     * @param showRadiosPanel the showRadiosPanel to set
     */
    public void setShowRadiosPanel(boolean showRadiosPanel) {
        this.showRadiosPanel = showRadiosPanel;
    }

    /**
     * @return the showServicesPanel
     */
    public boolean isShowServicesPanel() {
        return showServicesPanel;
    }

    /**
     * @param showServicesPanel the showServicesPanel to set
     */
    public void setShowServicesPanel(boolean showServicesPanel) {
        this.showServicesPanel = showServicesPanel;
    }

    /**
     * @return the checkForUpdate
     */
    public boolean isCheckForUpdate() {
        return checkForUpdate;
    }

    /**
     * @param checkForUpdate the checkForUpdate to set
     */
    public void setCheckForUpdate(boolean checkForUpdate) {
        this.checkForUpdate = checkForUpdate;
    }

    public void setIncludeThe(boolean includeThe) {
        this.includeThe = includeThe;
    }

    public boolean isIncludeThe() {
        return this.includeThe;
    }

    /**
     * @return the showNewMusicPanel
     */
    public boolean isShowNewMusicPanel() {
        return showNewMusicPanel;
    }

    /**
     * @param showNewMusicPanel the showNewMusicPanel to set
     */
    public void setShowNewMusicPanel(boolean showNewMusicPanel) {
        this.showNewMusicPanel = showNewMusicPanel;
    }
}
